﻿#ifndef COMPORT_H
#define COMPORT_H


#include <QObject>
#include <QTimer>
#include <QSettings>

#include "qextserial/qextserialport.h"

#ifdef Q_OS_LINUX
#define COMNAME     "/dev/ttyS1"
#define COMNAME485     "/dev/ttyS2"
#endif

class ComPort : public QObject
{
    Q_OBJECT
public:
    explicit ComPort(QObject *parent = 0);
    ~ComPort();
private:
    QextSerialPort * m_pSerialport;
    int m_running;
    QTimer * m_pReadTimer;
    QString m_portName;

public:
    void setComPortName(QString portName);//获取所有串口名称

private slots:
    void getDataFromPort();

signals:
    void siReceiveData(QByteArray dat);
    void siSerialPortOpenState(int val);

public slots:
    void initComm();
    void slotSendData(QByteArray dat);
};

#endif // COMTHREAD_H
